package rothag.views.gamestep;

import java.io.IOException;
import java.util.ArrayList;
import rothag.models.developpement.Developpement;
import rothag.controller.MainController;
import rothag.graphics.*;
import rothag.views.JPanelBase;
import rothag.listener.JoueurCourantListener;

/**
 *
 * @author Gaetan
 */
public class InfosJoueurJPanel extends JPanelBase implements JoueurCourantListener {

    private EtapeJeuJPanel etapeJeuJPanel;
    private SideDeveloppementJPanel developpementJPanel;
    private RessourcesJPanel ressourcesJPanel;
    private ScoreJPanel scoreJPanel;

    /** Creates new form InfosJoueurJPanel */
    public InfosJoueurJPanel(MainController controller) throws IOException {
        super(controller);

        controller.addJoueurCourantListener(this);

        // Définition de la taille
        hauteur = GraphicsParameters.infosJoueurHeight;
        largeur = GraphicsParameters.infosJoueurWidth;

        setOpaque(false);

        int x = 30;
        int y = 30;
        int espace = 12;

        // Etapes du jeu
        etapeJeuJPanel = new EtapeJeuJPanel(controller);
        GraphicsHelper.setBounds(x, y, etapeJeuJPanel);
        add(etapeJeuJPanel);

        y += espace + etapeJeuJPanel.getHauteur();

        // Développements
        developpementJPanel = new SideDeveloppementJPanel(controller);
        GraphicsHelper.setBounds(x, y, developpementJPanel);
        add(developpementJPanel);

        y += espace + developpementJPanel.getHauteur();

        // Ressources
        ressourcesJPanel = new RessourcesJPanel(controller);
        GraphicsHelper.setBounds(x, y, ressourcesJPanel);
        add(ressourcesJPanel);

        y += espace + ressourcesJPanel.getHauteur();

        // Score
        scoreJPanel = new ScoreJPanel(controller);
        GraphicsHelper.setBounds(x, y, scoreJPanel);
        add(scoreJPanel);
    }

    public EtapeJeuJPanel getEtapeJeuJPanel() {
        return etapeJeuJPanel;
    }

    public SideDeveloppementJPanel getDeveloppementJPanel() {
        return developpementJPanel;
    }

    public RessourcesJPanel getRessourcesJPanel() {
        return ressourcesJPanel;
    }

    public ScoreJPanel getScoreJPanel() {
        return scoreJPanel;
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        setAlignmentX(0.0F);
        setAlignmentY(0.0F);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 667, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 599, Short.MAX_VALUE)
        );
    }// </editor-fold>

    public void scoreChanged(int score) {
        scoreJPanel.setScore(score);
    }

    public void bateauChanged(int nbBateau) {
    }

    public void pieceChanged(int nbPiece) {
        ressourcesJPanel.setPieces(String.valueOf(nbPiece));
    }

    public void nourritureChanged(int nbNourriture) {
        ressourcesJPanel.setNourriture(String.valueOf(nbNourriture));
    }

    public void ouvrierChanged(int nbOuvrier) {
        ressourcesJPanel.setOuvrier(String.valueOf(nbOuvrier));
    }

    public void boisChanged(int nbBois) {
        ressourcesJPanel.setBois(String.valueOf(nbBois));
    }

    public void pierreChanged(int nbPierre) {
        ressourcesJPanel.setPierre(String.valueOf(nbPierre));
    }

    public void poterieChanged(int nbPoterie) {
        ressourcesJPanel.setPoterie(String.valueOf(nbPoterie));
    }

    public void tissuChanged(int nbTissu) {
        ressourcesJPanel.setTissu(String.valueOf(nbTissu));
    }

    public void ferDeLanceChanged(int nbFerDeLance) {
        ressourcesJPanel.setFerDeLance(String.valueOf(nbFerDeLance));
    }

    public void listeDeveloppementChanged(ArrayList<Developpement> listeDeveloppement) {
        developpementJPanel.setDeveloppement(listeDeveloppement);
    }
}
